<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>影片添加</span>
      </div>

      <From :form="form" @photo="photo">
        <!-- <Photos></Photos> -->
        <el-form-item>
          <el-button type="primary" @click="onSubmit" :loading="loading">立即创建</el-button>
          <!-- <el-button>取消</el-button> -->
        </el-form-item>
      </From>
    </el-card>
  </div>
</template>

<script>
import From from "./From";
export default {
  data() {
    return {
      loading: false,
      //存放表单数据
      form: {
        category: "",
        director: "",
        premiereAt: "",
        name: "",
        photos: [],
        actors: [
        
        ],
        poster: "",
        
      }
    };
  },
  created() {},
  components: {
    From
  },
  methods: {
    // async onSubmit() {
    //   //http://132.232.87.95:3000/admin
    //   let url = "http://132.232.87.95:3000/admin/film/add";
    //   try {
    //     this.loading = true;
    //     let data = this.form;
    //     console.log("data33333", data);
    //     await this.$axios.post(url, data);

    //     this.$message({
    //       message: "添加电影成功",
    //       type: "success"
    //     });
    //   } catch (error) {
    //     alert("网路不可用,请检查你的网络");
    //   }
    //   this.loading = false;
    // },
    async onSubmit() {
      this.loading = true;
      let url = "film/add";
      let data = this.form;
      console.log("添加总数据表：data", data);
      try {
        let result = await this.$axios.post(url, data);
        this.$message({
          message: "添加成功",
          type: "success"
        });

          //设置跳转
        setTimeout(() => {
          //
          this.$router.push({
            path: "/film/list"
          });
          }, 1000);
      } catch (error) {}
      this.loading = false;
    },
    //接受剧照穿回来的数据
    photo(data) {
      // this.form = {
      //   ...this.form,
      //   photos: data
      // };
      console.log("this.form", this.form);
    }
  }
};
</script>
<style>
.fond {
  font-size: 13.5px;
}
</style>
